04. Spring Data JPA

Javand305-C03-L02-A06-Spring-Data-Jpa 1

Repositories

There are 3 repository interfaces that you should know when you use Spring Data JPA:

As you might guess from its name, the CrudRepository interface defines a repository that offers standard create, read, update and delete operations. The PagingAndSortingRepository extends the CrudRepository and adds findAll methods that enable you to sort the result and to retrieve it in a paginated way. Both interfaces are also supported by other Spring Data projects, so that you can apply the same concepts to different datastores. The JpaRepository adds JPA-specific methods, like flush() to trigger a flush on the persistence context or findAll(Example example) to find entities by example, to the PagingAndSortingRepository.

Exercise

Task Description:

Students will rewrite the previous exercise to see how Spring Data JPA simplifies data access layer even further.

Task List:

Task Feedback:

Well done! You have used Spring Data JPA to manage entities.